package com.car.controller;

import com.car.entity.Detailedlistofrentalcharges;
import com.car.service.DetailedlistofrentalchargesService;
import com.car.vo.DetailedlistofrentalchargesVo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("/zucheMoney")
public class DetailedlistofrentalchargesController   {

	
	@Autowired
	DetailedlistofrentalchargesService detailedlistofrentalchargesService;
	/**
	 * 租車租金顯示
	    * @Title: toMoneyinfos
	    * @Description: TODO(这里用一句话描述这个方法的作用)
	    * @param @param orderId
	    * @param @param rentDays
	    * @param @param pageIndex
	    * @param @param orderS
	    * @param @param model
	    * @param @return    参数
	    * @return String    返回类型
	    * @throws
	 */
	@RequestMapping({"/TomoneyInfos",""})
	public String toMoneyinfos(String orderId,@RequestParam(value="rentDays",defaultValue="1")Integer rentDays,
			@RequestParam("pageIndex")Integer pageIndex,
			@RequestParam("orderS")String orderS,
			@RequestParam("i")String i,
			Model model){
		DetailedlistofrentalchargesVo detaile = detailedlistofrentalchargesService.selectByPrimaryKey(orderId);
		if(rentDays<1){
			rentDays =1;
		}
		int vehicleCostt = detaile.getVehicleCost();
		int basicServiceCharget =0;
		int honourServicet= 0;
		if(detaile.getBasicServiceCharge()>1){
			 basicServiceCharget = detaile.getBasicServiceCharge()/rentDays;
		}
		if(detaile.getHonourService()>0){
			 honourServicet = detaile.getHonourService()/rentDays;
		}

		Map<String, Object> maps = new HashMap<>();
		maps.put("vehicleCostt", vehicleCostt);
		maps.put("basicServiceCharget", basicServiceCharget);
		maps.put("honourServicet", honourServicet);
		maps.put("days", rentDays);
		model.addAttribute("deta", detaile);
		model.addAttribute("pageIndex", pageIndex);
		model.addAttribute("i", i);
		model.addAttribute("maps", maps);
		model.addAttribute("orderS", orderS);
		return "H5phone/RentDetail";
	}

}